<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<link>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录页面</title>
    <link rel="stylesheet" href="https://cdn.bootcss.com/font-awesome/5.13.0/css/all.css"/>
    <link rel="stylesheet" th:href="@{/computer/css/login.css}"type="text/css"/>
    <link rel="stylesheet" href="//unpkg.com/layui@2.6.8/dist/css/layui.css">
　  <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
    <script src="//unpkg.com/layui@2.6.8/dist/layui.js"></script>

</head>

<body>
<div id="login_box">
    <h2>家政网 </h2>
    <div id="form">
        <div class="input_box">
            <i class="fa fa-user" aria-hidden="true"></i>
            <input class="in" type="text" placeholder="Username" id="uname">
        </div>
        <div class="input_box">
            <i class="fa fa-key" aria-hidden="true"></i>
            <input class="in" type="passwoprd" placeholder="Passwoprd" id="password">
        </div>
        <!--<div class="input_box">-->
            <!--<input id=inputValidatecode name="inputValidatecode"  placeholder="验证码"  type="text" class="in">-->
            <!--<img src="/validatecode"/>-->
        <!--</div>-->
    </div>

    <button class="btn btn-default" onclick="login()">登录</button>
    <button class="btn btn-primary" onclick="toregister()">注册</button><br>
    <div id="Sign">
        <a href="a">忘记密码?</a>
    </div>
</div>
</body>
<script>
function login(){

    $.ajax({
        type:"get",
        dataType:"json",
        data:{uname:$("#uname").val(),upass:$("#password").val(),inputValidatecode:$("#inputValidatecode").val()},
        url:"/login",
        success:function(backVal){
            if (backVal.code ==0){
                layer.msg("登录成功",{
                    icon:1,
                    time:2000
                },function(){
                    window.location.href="/toindex"
                })
            } else if(backVal.code==-2){
                layer.msg("没有此账号",{
                    icon:2,
                    time:2000
                });
            }
            else if(backVal.code==-5){
                layer.msg("登陆失败",{
                    icon:2,
                    time:2000
                });
            }
            else if(backVal.code==-7){
                layer.msg("验证码错误",{
                    icon:2,
                    time:2000
                });
            }
            else{
                layer.msg("认证失败",{
                    icon:2,
                    time:2000
                });
            }

        }
    })
}
function  toregister() {
    window.location.href = "/toregister"

}
</script>
</html>